#如果某玩家无游玩权限将永远处于观战状态（最高优先级）
gamemode spectator @a[tag=WatchForever]


#进入战斗的玩家带有Alive标签观战中的带有Watch
#强制死亡：无视重生效果
scoreboard players set @a[scores={SystemDeath=2}] EFReborn 0
#玩家死亡后（没有重生效果）赋予Watch标签：
execute as @a[scores={SystemDeath=1..,EFReborn=0}] run function nw:system/system_util/reset
execute as @a[scores={SystemDeath=1..,EFReborn=0}] run tag @s remove BuyHero
execute as @a[scores={SystemDeath=1..,EFReborn=0}] run tag @s remove Buying
execute as @a[scores={SystemDeath=1..,EFReborn=0}] run team join Watch @s
execute as @a[scores={SystemDeath=1..,EFReborn=0},tag=Alive] run tag @s remove Alive
execute as @a[scores={SystemDeath=1..,EFReborn=0},tag=!Watch] run tag @s add Watch
#若死亡时处于大逃杀对局中，则执行对应函数
execute if score IsTheDieOutGame SystemAdmin matches 3.. as @a[scores={SystemDeath=1..,EFReborn=0}] at @s run function nw:system/system_module/dieout_util_die
#如果有效果：重生，则本次死亡直接移除重生效果
scoreboard players set @a[scores={SystemDeath=1..},tag=Alive] EFReborn 0
scoreboard players set @a[scores={SystemDeath=1..,EFReborn=0}] SystemDeath 0

#观战玩家固有：隐身 虚弱 饱和 回血
execute as @a[tag=Watch,tag=!BuyHero] unless data entity @s Inventory[{id: "minecraft:player_head"}] run item replace entity @s armor.head with minecraft:player_head{AttributeModifiers: [{Operation: 1, Amount: 0.1d, UUID: [I; 634770312, -450856290, -329401498, 1797269479], Slot: head, AttributeName: "generic.movement_speed", Name: "generic.movementSpeed"}, {Operation: 0, Amount: +1, UUID: [I; 678582379, -1312048115, -266626997, -1862194313], Slot: head, AttributeName: "generic.knockback_resistance", Name: "generic.knockbackResistance"}, {Operation: 0, Amount: +20, UUID: [I; 625424525, -994414530, -384964899, 1473586457], Slot: head, AttributeName: "generic.armor", Name: "generic.armor"}, {Operation: 0, Amount: +10, UUID: [I; 618052511, 2021803018, -436863524, -1579549140], Slot: head, AttributeName: "generic.armor_toughness", Name: "generic.armorToughness"}], HideFlags: 2} 1
effect give @a[tag=Watch,tag=!BuyHero] invisibility 2 9 true
effect give @a[tag=Watch] weakness 2 9 true
effect give @a[tag=Watch,tag=!BuyHero,scores={skHealth=..36}] instant_health 1 0 true
effect give @a[tag=Watch,tag=!BuyHero] minecraft:saturation 2 9 true
